package com.test.application.designPatterns.principles_design.lishizhuanhuan.before;

public class RectangleDemo {

    public static void main(String[] args) {
//        Rectangle rectangle = new Rectangle(20, 30);
        Rectangle rectangle = new Square();//如果是正方形，则运行出错，不符合里氏代换原则
        rectangle.setLength(15);
        resize(rectangle);
        show(rectangle);
    }


    //扩宽
    public static void resize(Rectangle rectangle) {
        //宽比长小，宽+1
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    public static void show(Rectangle rectangle) {
        System.out.println("长：" + rectangle.getLength() + "，宽：" + rectangle.getWidth());
    }
}
